<template>
	<view>
		<view>{{count}}</view>
		<view class="title">我是标题</view>
		<button @click="setCount">我也改变count</button>
		<button @click="jumpWebView">跳转到webView</button>
		<button @click="call">拨打电话</button>
		<button @click="handleClick1">震动</button>
		<button @click="queryList">获取数据</button>
	</view>
</template>

<script lang="ts" setup>
	import { storeToRefs } from 'pinia'
	import { onLoad, onShow, onReady } from '@dcloudio/uni-app'
	import { useStore } from '../../stores/user.js'
	import { onBeforeMount, onMounted } from 'vue'
	
	const { count } = storeToRefs(useStore())
	const { setCount } = useStore()
	
	const jumpWebView = () => {
		uni.navigateTo({
			url: '/pages/logs/logs?url=https://www.dcloud.io/'
		})
	}
	
	const call = () => {
		uni.makePhoneCall({
			phoneNumber: '114',
			success: () => {
				console.log('拨打成功');
			},
			fail: () => {
				console.log('拨打失败');
			}
		})
	}
	
	const handleClick1 = () => {
		uni.vibrateLong({
			success: function () {
				console.log('success');
			}
		});
	}
	
	const queryList = () => {
		uni.request({
			url: 'http://192.168.21.233:3000/users',
			success: (result) => {
				console.log('拿到了数据', result);
			},
			fail: (err) => {
				console.log('获取失败了', err);
			}
		})
	}
</script>

<style lang="less" scoped>
.title {
	/* #ifdef MP-WEIXIN */
	color: red;
	/* #endif */
	
	/* #ifdef H5 */
	color: blue;
	/* #endif */

	/* #ifdef APP */
	color: green;
	/* #endif */
}
</style>
